<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<SCRIPT LANGUAGE="JavaScript">

function chkData(text){ 
tmp =document.all.item("text").value;
if (tmp != "")
searchpro.submit();
else {
alert("Enter Name");
document.all.item("text").focus();
searchpro.submit(); 
}
}
</SCRIPT>
</head>

<body>
<div id="Layer26">
  <table width="983" height="58" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td height="40" colspan="5">
        <p class="style30">ระบบการค้นหาข้อมูล</p>
        <hr />
        <p>&nbsp;</p></td>
    </tr>
    <tr>
      <td width="140" align="right">
	  <form name="searchpro" method="post" action="Search system.php">
            <select name="selectpro">
              <option selected="selected">ชื่อเจ้าของผลงาน</option>
			  <option>รหัสนักศึกษา</option>
              <option>ชื่อสาขา</option>
              <option>ชื่อรายวิชา</option>
              <option>ชื่อผลงาน</option>
            </select>
      </td>
      <td width="100">
          <input type="text" size="40" name="text" />
      </td>
		<td width="120" align="center">ประเภทผลงาน</td>
		<td width="100">
	  <select name="type">
	  <option>เลือกประเภทผลงาน</option>
	  <? require("../connectDB.php");
	$query_list=mysql_query("Select * From project_type");
	while($arrL= mysql_fetch_array($query_list))
	{
	?>
	<option><? echo $arrL['project_type'];?></option>
	<?
	}
	mysql_free_result($query_list);
	?>
	</select>
	</td>
	<td align="left" width="400">&nbsp;&nbsp 
    <input type="button" name="btn" onclick="chkData(text)" value="ค้นหา" />
	</td>
    </tr>
  </table>
  </form>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; </p>
<div id="Layer35">
  <table width="850" height="94" border="1" cellpadding="2" cellspacing="0" bordercolor="#999999">
    <tr>
      <td width="75" height="45" bgcolor="#0099CC"><div align="center" class="style29">ชื่อสาขา</div></td>
      <td width="120" bgcolor="#0099CC"><div align="center" class="style29">ชื่อรายวิชา</div></td>
      <td width="160" bgcolor="#0099CC"><div align="center" class="style29">ชื่อเจ้าของผลงาน</div></td>
      <td bgcolor="#0099CC"><div align="center" class="style29">ชื่อผลงาน</div></td>
      <td width="104" bgcolor="#0099CC"><div align="center" class="style29">สถานะผลงาน</div></td>
      <td width="100" bgcolor="#0099CC"><div align="center" class="style29">
        <div align="center">วันที่อัพโหลดข้อมูล</div>
      </div></td>
    </tr>
<? require("../connectDB.php");    //include "connectdb.inc";
if ($type == "เลือกประเภทผลงาน"){
if ($list == "ชื่อผลงาน")
$tmp="select * from project where project_name like '$text%' order by project_id;";
else if ($selectpro == "ชื่อเจ้าของผลงาน")
$tmp="select * from project where owner_name like '$text%' order by student_id;";
else if ($list == "ชื่อรายวิชา")
$tmp="select * from project where subject like '$text%' order by project_id;";
else if ($list == "ชื่อสาขา")
$tmp="select * from project where major like '$text%' order by project_id;";
else if ($selectpro == "รหัสนักศึกษา")
$tmp="select * from project where student_id like '$text%' order by student_id;";
else if ($text == "")
$tmp="select * from project order by project_id;";
}
else if ($selectpro == "ชื่อเจ้าของผลงาน")
$tmp="select * from project where owner_name like '$text%' and project_type like '$type' order by student_id;";
else if ($selectpro == "รหัสนักศึกษา")
$tmp="select * from project where student_id like '$text%' and project_type like '$type' order by student_id;";
elseif ($selectpro == "ชื่อสาขา")
$tmp="select * from project where major like '$text%' and project_type like '$type' order by student_id;";
else if ($selectpro == "ชื่อรายวิชา")
$tmp="select * from project where subject like '$text%' and project_type like '$type' order by student_id;";
else if ($selectpro == "ชื่อผลงาน")
$tmp="select * from project where project_name like '$text%' and project_type like '$type' order by student_id;";
else
$tmp="select * from project order by student_id;";

//echo($tmp);
$sql = mysql_query($tmp);
while($result = mysql_fetch_array($sql))    { ?>
<TR>
<TD align="center"><? echo $result["major"]; ?></TD>
<td><? echo $result["subject"]; ?></td>
<td><? echo $result["owner_name"]; ?></td>
<TD><a href="showProject.php?pname=<? echo $result["project_name"]; ?>" > <? echo $result["project_name"]; ?></TD>
<TD align="center"><? echo $result["project_status"]; ?></td>
<TD><? echo $result["upload_date"]; ?></td>
</tr>
<? }
mysql_free_result($sql);
mysql_close($con); ?>
</table>
</body>
</html>
